#ifndef SERIAL__ROBOT_BASE_NODE_HPP_
#define SERIAL__ROBOT_BASE_NODE_HPP_

#include <memory>
#include <thread>

#include <ros/ros.h>

#include "rm_interfaces/SerialSendMsg.h"
#include "rm_interfaces/SerialReceiveMsg.h"
#include "rm_interfaces/SetMode.h"
#include "serial/fixed_packet_tool.hpp"
#include "serial/transporter_interface.hpp"
#include "serial/uart_transporter.hpp"

namespace serial {
class RobotBaseNode {
 public:
  RobotBaseNode();

 public:
  void listen_loop();

 private:
  void gimbal_cmd_cb(const rm_interfaces::SerialSendMsgConstPtr &msg);

 private:
  ros::NodeHandle nh_;
  ros::Publisher joint_state_pub_;
  ros::Publisher bullet_speed_pub_;
  ros::ServiceClient set_mode_client_;

  std::unique_ptr<std::thread> listen_thread_;
  TransporterInterface::SharedPtr transporter_;
  FixedPacketTool<16>::SharedPtr packet_tool_;

  int mode_;
  bool first_recv_;
  bool first_send_;
  float bullet_speed_;
  float yaw_;
  float pitch_;
  ros::Subscriber sub_;
  ros::Publisher pub_;
};

}  // namespace serial

#endif  // SERIAL__ROBOT_BASE_NODE_HPP_
